from common.custom_list_tools.ListHelper import ListHelper


class Skill:
    def __init__(self, no, name, cd, atk, mp):
        self.no = no
        self.name = name
        self.cd = cd
        self.atk = atk
        self.mp = mp

    def __str__(self):
        return '%s,%s,%s,%s,%s' % (self.no, self.name, self.cd, self.atk, self.mp)


list_skill = [
    Skill('101', '誓约之盾', '3', '5', '0'),
    Skill('102', '回旋打击', '3', '7', '0'),
    Skill('103', '圣剑裁决', '10', '15', '0'),
    Skill('104', '凋零冰晶', '3', '6', '1'),
    Skill('105', '禁锢寒霜', '5', '8', '2'),
    Skill('106', '凛冬已至', '10', '20', '6'),
    Skill('-1', '普通攻击', '0', '2', '0')
]

list_skill_name = [item.name for item in list_skill]
print(list_skill_name)

print(list(ListHelper.find_item_property(list_skill, lambda item: item.name)))

print(ListHelper.sum_item_property(list_skill, lambda item: int(item.no)))

print(ListHelper.sum_item_property(list_skill, lambda item: int(item.cd)))
